﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Appraisal_System_Utility
{

  public static  class Tomodel
    {
        //扩展方法  --- 泛型反射(和普通的tomodel 逻辑一样）
        public static T DataRowToModel<T>(this DataRow dr)
        {
            Type type = typeof(T);
            T t =(T) Activator.CreateInstance(type);
            foreach(var prop in type.GetProperties())
            {
                prop.SetValue(t, dr[prop.Name]);
            }
            return t;
        }
    }
}
